/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ggsoft.timetracker.domain;

import com.ggsoft.timetracker.utils.Persistent;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;

/**
 *
 * @author giovanella
 * @date May 17, 2014
 */
@Entity
@Table(name = "departments")
public class Department implements Serializable, Persistent {

    private Long id;
    private String code;
    private String initials;
    private String description;

    public Department() {
    }

    public Department(Long id, String code, String initials, String description) {
        this.id = id;
        this.code = code;
        this.initials = initials;
        this.description = description;
    }
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @DocumentId
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(nullable = false, length = 50, unique = true)
    @Field
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Column(nullable = false, length = 50, unique = true)
    @Field
    public String getInitials() {
        return initials;
    }

    public void setInitials(String initials) {
        this.initials = initials;
    }
    
    @Column(nullable = false, length = 200)
    @Field
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Department)) {
            return false;
        }
        Department _i = (Department) obj;
        return id.equals(_i.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }        
}
